package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.system.domain.StationeryTemplates;
import com.hello.system.service.IStationeryTemplatesService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 信笺模板管理Controller
 * 
 * @author hello
 * @date 2025-05-15
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/templates")
public class StationeryTemplatesController extends BaseController
{
    private final IStationeryTemplatesService stationeryTemplatesService;

    /**
     * 查询信笺模板管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(StationeryTemplates stationeryTemplates)
    {
        startPage();
        List<StationeryTemplates> list = stationeryTemplatesService.selectStationeryTemplatesList(stationeryTemplates);
        return getDataTable(list);
    }

    /**
     * 导出信笺模板管理列表
     */
    @Log(title = "信笺模板管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StationeryTemplates stationeryTemplates)
    {
        List<StationeryTemplates> list = stationeryTemplatesService.selectStationeryTemplatesList(stationeryTemplates);
        ExcelUtil<StationeryTemplates> util = new ExcelUtil<StationeryTemplates>(StationeryTemplates.class);
        util.exportExcel(response, list, "信笺模板管理数据");
    }

    /**
     * 获取信笺模板管理详细信息
     */
    @GetMapping(value = "/{templateId}")
    public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
    {
        return success(stationeryTemplatesService.selectStationeryTemplatesByTemplateId(templateId));
    }

    /**
     * 新增信笺模板管理
     */
    @Log(title = "信笺模板管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationeryTemplates stationeryTemplates)
    {
        return toAjax(stationeryTemplatesService.insertStationeryTemplates(stationeryTemplates));
    }

    /**
     * 修改信笺模板管理
     */
    @Log(title = "信笺模板管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationeryTemplates stationeryTemplates)
    {
        return toAjax(stationeryTemplatesService.updateStationeryTemplates(stationeryTemplates));
    }

    /**
     * 删除信笺模板管理
     */
    @Log(title = "信笺模板管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{templateIds}")
    public AjaxResult remove(@PathVariable Long[] templateIds)
    {
        return toAjax(stationeryTemplatesService.deleteStationeryTemplatesByTemplateIds(templateIds));
    }
}
